begin
  require 'hpricot'
rescue LoadError
  require 'rubygems'
  require 'hpricot'
end
require 'net/http'

module MarketPrice
	@@input = ""
	
	
	def self.fetch(id)
    @http = Net::HTTP.new('eve-central.com')
    resp, data = @http.get2("/home/quicklook.html?typeid=" + id.to_s, {'User-Agent' => "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.0.7) Gecko/20060909" })
		@@input = resp.body
    
	end
	
	def self.get_median_sell(id)
		self.fetch(id)
		m = @@input.match(/selling\ price\ in\ view\:\<\/b\> (.*) ISK/)
		return m[1].gsub(",","").to_f
	end
end

